package com.deyuanyun.pic.pipe.controller.vo.merge;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.controller.vo.BaseVO;
import com.deyuanyun.pic.pipe.controller.vo.BaseVOUtil;
import com.deyuanyun.pic.pipe.domain.Marker;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

/**
 * 埋地标识信息表
 */
public class MarkerVO extends BaseVO<Marker> {

    // 管道名称
    private String pipeLineName;
    // 标识器编号
    private String markerNumber;
    // 出厂编号
    private String manufacturedNum;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // 标识类型
    private String markerType;
    // 生产厂商
    private String manufacturer;
    // 安装日期
    private String installDate;
    // 施工单位
    private String assemblyCompany;
    // 标识器埋深
    private String markerDepth;
    // 地图id
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getMarkerNumber() {
        return markerNumber;
    }

    public void setMarkerNumber(String markerNumber) {
        this.markerNumber = markerNumber;
    }

    public String getManufacturedNum() {
        return manufacturedNum;
    }

    public void setManufacturedNum(String manufacturedNum) {
        this.manufacturedNum = manufacturedNum;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getMarkerType() {
        return markerType;
    }

    public void setMarkerType(String markerType) {
        this.markerType = markerType;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getInstallDate() {
        return installDate;
    }

    public void setInstallDate(String installDate) {
        this.installDate = installDate;
    }

    public String getAssemblyCompany() {
        return assemblyCompany;
    }

    public void setAssemblyCompany(String assemblyCompany) {
        this.assemblyCompany = assemblyCompany;
    }

    public String getMarkerDepth() {
        return markerDepth;
    }

    public void setMarkerDepth(String markerDepth) {
        this.markerDepth = markerDepth;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    @Override
    public void fromDomain(Marker domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 标识器编号
        this.markerNumber = domain.getMarkerNumber();
        // 出厂编号
        this.manufacturedNum = domain.getManufacturedNum();
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 标识类型
        this.markerType = CodeUtil.getName(domain.getMarkerType());
        // 生产厂商
        this.manufacturer = domain.getManufacturer();
        // 安装日期
        this.installDate = DateFormat.format(domain.getInstallDate());
        // 施工单位
        this.assemblyCompany = domain.getAssemblyCompany();
        // 标识器埋深
        this.markerDepth = NumberFormat.format(domain.getMarkerDepth(), NumberFormat.FMT_PLACES3);
        // 链接GIS结果表
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<MarkerVO> fromDomainList(Page<Marker> domainList) {
        Page<MarkerVO> list = new Page<MarkerVO>();
        for (Marker marker : domainList) {
            MarkerVO markerVO = new MarkerVO();
            markerVO.fromDomain(marker);
            list.add(markerVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }
}